package com.cly.controller;

import com.cly.base.controller.BaseController;
import com.cly.entity.CourseNode;
import com.cly.result.JsonRequest;
import com.cly.service.ICourseNodeService;
import com.cly.vo.CourseNodeVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 课节表业务层实现
 *
 * @author 春风能解释
 * <p>
 * 2024-06-06
 */
@RestController
@RequestMapping("/courseNode")
@Tag(name = "课节表控制类", description = "课节表操作访问接口")
public class CourseNodeController extends BaseController<ICourseNodeService, CourseNode> {
    /**
     * 根据条件查询课节表信息
     *
     * @param current    页码
     * @param size       页长
     * @param courseNode 条件
     * @return JSON
     */
    @GetMapping("/list")
    @Operation(summary = "根据条件查询课节表信息")
    public JsonRequest<List<CourseNodeVo>> lookCourseNode(
            @Parameter(description = "页码", required = true)
            @RequestParam Integer current,
            @Parameter(description = "页长", required = true)
            @RequestParam Integer size,
            @Parameter(description = "课节表条件")
            CourseNode courseNode) {
        return baseService.lookCourseNode(current, size, courseNode);
    }

    /**
     * 新增一条课节表信息
     *
     * @param courseNode 课节表信息
     * @return JSON
     */
    @PostMapping
    @Operation(summary = "新增一条课节表信息")
    public JsonRequest<Integer> addOneCourseNode(
            @Parameter(description = "课节表信息", required = true)
            @RequestBody CourseNode courseNode) {
        return baseService.addOneCourseNode(courseNode);
    }

    /**
     * 修改一条课节表信息
     *
     * @param courseNode 课节表信息
     * @return JSON
     */
    @PutMapping
    @Operation(summary = "修改一条课节表信息")
    public JsonRequest<Integer> updateOneCourseNode(
            @Parameter(description = "课节表信息", required = true)
            @RequestBody CourseNode courseNode) {
        return baseService.updateOneCourseNode(courseNode);
    }

    /**
     * 批量删除课节表信息
     *
     * @param ids 课节表id列表
     * @return JSON
     */
    @DeleteMapping
    @Operation(summary = "批量删除课节表信息")
    public JsonRequest<Integer> deleteCourseNodes(
            @Parameter(description = "课节表id列表", required = true)
            @RequestBody List<Long> ids) {
        return baseService.deleteCourseNodes(ids);
    }


}